﻿
IF object_id(N'dbo.UDS_Staff_In_Role', 'U') IS NULL
BEGIN
    CREATE TABLE [dbo].[UDS_Staff_In_Role] (
        [Staff_ID] int NOT NULL,
        [Role_ID]  int NULL,

        CONSTRAINT [FK_UDS_Staff_In_Role_UDS_Role] FOREIGN KEY ([Role_ID]) REFERENCES [dbo].[UDS_Role] ([Role_ID]),
        CONSTRAINT [FK_UDS_Staff_In_Role_UDS_Staff] FOREIGN KEY ([Staff_ID]) REFERENCES [dbo].[UDS_Staff] ([Staff_ID])
    );
END
GO

SET NOCOUNT ON
IF NOT EXISTS (SELECT 1 FROM dbo.[UDS_Staff_In_Role])
BEGIN
    INSERT INTO dbo.[UDS_Staff_In_Role] (Staff_ID, Role_ID) VALUES(1, 1);
END
GO